<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0,maximum-scale=1.0"/>
    <script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/style.css"/>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/public.js" type="text/javascript" charset="utf-8"></script>
    <title>扫码点餐-首页</title>
</head>
<body>
<div id="home" style="background:url(__PUBLIC__{$store_info.bg_image}) no-repeat center top / 100%;">
    <div id="store_name" class="conTitle">{$store_info.store_name}</div>
    <div id="store_logo" class="conLogo">
        <img class="logo" src="__PUBLIC__{$store_info.logo}"/>
        <span class="logoName">{$store_info.store_name}</span>
    </div>
    <div class="conBar">
        <a href="{:U('Home/Reserve/index')}" class="list">
            <img class="listIcon" src="__PUBLIC__/images/icon_canju@1x.png"/>
            <span class="listName">预定点餐</span>
        </a>
        <a href="{:U('Home/Index/main')}" class="list">
            <img class="listIcon" src="__PUBLIC__/images/icon_diancan@1x.png"/>
            <span class="listName">开始点餐</span>
        </a>
        <a href="javascript:void(0);" class="list">
            <img class="listIcon" src="__PUBLIC__/images/icon_fuwuyuan@1x.png"/>
            <span class="listName">叫服务员</span>
        </a>
        <a href="{:U('Home/Coupon/index')}" class="list">
            <img class="listIcon" src="__PUBLIC__/images/icon_yhq@1x.png"/>
            <span class="listName">领优惠券</span>
        </a>
    </div>
    <div class="conList">
        <div class="explain">
            成为会员享受更多优惠权益
            <a href="javascript:void(0);" class="go_kt">去开通</a>
        </div>
        <div class="ft_txt">
            <p>邦伲德（上海）网络技术有限公司 技术支持</p>
            <p>Copyright © 2018 bonnidee. All Rights Reserved.</p>
        </div>
    </div>
    <p></p>
</div>

<script type="text/javascript">
    //适配
    //(function() {
    //      var newRem = function() {
    //          var html = document.documentElement;
    //          html.style.fontSize = html.getBoundingClientRect().width / 16 + 'px';
    //      };
    //      window.addEventListener('resize', newRem, false);
    //      newRem();
    //  })();

    $(function () {
        //获取地址栏参数
        (function ($) {
            $.getUrlParam = function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return '';
            }
        })
        (jQuery);

        //清空购物车
        $.ajax({
            url: url() + "index.php/Api/Car/del",
            dataType: "json",
            type: "get",
            success: function (data) {
                // console.log(data)
            }
        })

        var store_id = $.getUrlParam('store_id');//店铺id

        var table_id = $.getUrlParam('table_id');//桌号

        //获取用户信息
        getUserInfo(store_id);
    })

    //获取用户信息
    function getUserInfo(store_id) {
        var store_id = store_id;
        $.ajax({
            // url: url() + 'index.php/Api/Index/getUserInfo',    //请求的url地址
            url:"{:U('Api/Index/getUserInfo')}",   //请求的url地址
            dataType: "json",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "GET",   //请求方式
            data: {
                store_id: store_id,
            },
            success: function (data) {
                if (data.state == 1) {
                    window.location.href = url() + "index.php?m=Api&c=WeChat&a=start&store_id=" + store_id;//微信授权登录
                } else {
                    console.log(data)
                    var storage = window.localStorage;
                    storage.setItem("customer_id", data.data.customer_id)
                }
            }
        });
    }

</script>

</body>
</html>